import threading
import time


class mythread(threading.Thread):
    counter = 0;
    name = ""

    def __init__(self, counter, name):
        threading.Thread.__init__(self)
        self.counter = counter;
        self.name = name;
        print("init")

    def run(self):
        threadLock.acquire()
        printrunn(0, self.name);
        threadLock.release()


threadLock = threading.Lock()


def printrunn(counter, name):
    while counter < 5:
        counter += 1;
        print("counter==" + str(counter) + ",name===" + name)
        time.sleep(0.2)


print("thread begin")
t1 = mythread(5, "thread-1")
t2 = mythread(5, "thread-2")

t1.start()
t2.start();

threads = []
threads.append(t1);
threads.append(t2);
for i in threads:
    i.join();
print("end--")
